/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.oai.provider.response.listRequests;

import cz.mzk.oai.metadataRepository.repository.records.Record;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 *
 * @author Martin Řehánek <rehan at mzk.cz>
 */
public class CompleteList {

    private final List<Record> records;

    public CompleteList(Set<Record> records) {
        this.records = new ArrayList<Record>(records);
    }

    public int totalSize() {
        return records.size();
    }

    List<Record> getRecords(int start, int maxEnd, int maxLength) {
        if (start < 0) {
            throw new IllegalArgumentException("from cannot be negative");
        }
        if (maxEnd <= 0) {
            throw new IllegalArgumentException("to cannot be negative");
        }
        if (maxLength < 0) {
            throw new IllegalArgumentException("maxLength must be positive");
        }
        int realEnd = (start + maxLength) > records.size() ? records.size() : (start + maxLength);
        return records.subList(start, realEnd);
    }
}
